from collections import Generator, Iterable, Iterator


class MyRange:
    def __init__(self, end_number):
        self.end_number = end_number

    def __iter__(self):
        star_value = 0
        while star_value < self.end_number:
            yield star_value
            star_value += 1


if __name__ == '__main__':
    manager = MyRange(10)
    print(type(manager))
    print(isinstance(manager, Iterable))
    print(isinstance(manager, Iterator))
    print(isinstance(manager, Generator))
    # iterator = manager.__iter__()   #产生一个迭代器对象
    iterator = iter(manager)
    while True:
        try:
            item = iterator.__next__()
            print(item)
        except StopIteration:
            break

if __name__ == '__main__':
    for i in MyRange(10):
        print(i)
